package com.weaver.qfengx;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Created by YeShengtao on 2020/10/26 12:08
 */
public class LogUtils {

    private Log log = null;

    public LogUtils(Class clazz) {
        log = LogFactory.getLog(clazz);
    }

    public LogUtils() {
        log = LogFactory.getLog(this.getClass());
    }

    public void writeLog(Object obj) {
        writeLog(this.getClass().getName(), obj);
    }

    public void writeLog(String name, Object obj) {
        if (obj instanceof Exception) {
            log.error(name, (Exception) obj);
        } else {
            log.error(obj);
        }
    }

    public void error(Object obj) {
        log.error(obj);
    }

    public void debug(Object obj) {
        log.debug(obj);
    }

    public void info(Object obj) {
        log.info(obj);
    }
}
